import Vue from 'vue'
import VueRouter from 'vue-router'
const HomeContainer = () => import('@/components/tabbar/HomeContainer')
const MemberContainer = () => import('@/components/tabbar/MemberContainer')
const SearchContainer = () => import('@/components/tabbar/SearchContainer')
const ShopcarContainer = () => import('@/components/tabbar/ShopcarContainer')
const NewsList = () => import('@/components/news/NewsList')
const NewsInfo = () => import('@/components/news/NewsInfo')
const PhotoList = () => import('@/components/photos/PhotoList')
const PhotoInfo = () => import('@/components/photos/PhotoInfo')
const GoodsList = () => import('@/components/goods/GoodsList')
const GoodsInfo = () => import('@/components/goods/GoodsInfo')
const GoodsDesc = () => import('@/components/goods/GoodsDesc')
const GoodsComment = () => import('@/components/goods/GoodsComment')




const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/home' },
  { path: '/home', component: HomeContainer },
  { path: '/member', component: MemberContainer },
  { path: '/search', component: SearchContainer },
  { path: '/shopcar', component: ShopcarContainer },
  { path: '/home/newslist', component: NewsList },
  { path: '/home/newsinfo/:id', component: NewsInfo },
  { path: '/home/photolist', component: PhotoList },
  { path: '/home/photoinfo/:id', component: PhotoInfo },
  { path: '/home/goodslist', component: GoodsList },
  { path: '/home/goodsinfo/:id', component: GoodsInfo, name: 'goodsinfo' },
  { path: '/home/goodsdesc/:id', component: GoodsDesc, name: 'goodsdesc' },
  { path: '/home/goodscomment/:id', component: GoodsComment, name: 'goodscomment' },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,

  linkActiveClass: 'mui-active' //覆盖默认的高亮的类,默认的类叫做router-link-active
})

export default router